4.4 Pointer to Member function (Pointer-to-member Functions)take a nonstatic data member address, the result is the member in the class layout of the byte position (plus 1), it is an incomplete value, need to be bound to the address of a class
4.4 Pointer to Member function (Pointer-to-member Functions)take a nonstatic data member address, the result is the member in the class layout of the byte position (plus 1), it is an incomplete value, need to be bound to the address of a class
Refer to the relevant chapter of "Pointer to a class member function", which includes the term "class member function", but strictly speaking, the member function here only refers to a non-static member function, this term also contains the term
Refer to the relevant chapter of "Pointer to a class member variable". This term contains the term "class member variables", but strictly speaking, the member variables here only refer to non-static member variables, this term also contains the term
A constant pointer to an object
Declare the pointer variable to the object as a const and initialize it so that the pointer value remains at its initial value and cannot be changed.
Copy Code code as follows:
Time T1 (10,12,15), T2;
1Pointer to a class member
1.1Concept
Unlike a regular pointer, a pointer to a class member does not point to a specific position. It points to a specific member of a class rather than a specific member of a specific object. Usually, the pointer
Constant (volume) pointersA constant pointer is a pointer to a constant that we refer to as the name implies.
Pointing to constant variables with constant pointersIn fact, the C + + rule can only use the pointer to the constant variable, the normal
To modify the value of a variable, you need to use a pointer to the variable type as a reference to the argument or variable. If the variable is a generic type of variable, such as int, you need to use a pointer of type int int * As the argument or
Assume that the screen class defines four new member functions: Forward () Back () Up () and down (). They move the cursor to the right, left, up, and down, respectively. First, we declare these new member functions in the class body:
Class Screen
a) An integer number (an integer)b) A pointer to the integer number (a pointer to an integer)c) A pointer to a pointer to a pointer that points to a number of integers (a pointer to a pointer to an intege) rd) An array of 10 integers (an arrays of
[Switch] usage of C ++ pointer to class member (details)
Default category: 20:39:57 read 176 comments 0 font size: LargeMediumSmall subscription
1. First, the normal function pointer cannot be assigned as the address of the member function, even if
The array name represents the first address of the array, and then the address of the array, its value is still the same.Int A [5] = {1, 2, 3, 4, 5}; A, & A their values are the same
Returns the address of an array. The type can be used as a
directory of this document
Objective
A function that returns a pointer
Second, pointers to functions
Description: This C language topic is the prelude to learning iOS development. And for programmers with an object-oriented
1. pointer to the const objectWe can use a pointer to modify the value of the object it refers to. However, if the pointer points to a const object, it is not allowed to use a pointer to change the const value it refers. C ++ requires that the
One: Related concepts1. Array of pointers: int *p[6] is an array, which is an array of pointers, which is where the address is stored.2. Array pointer : Int (*p) [6] is a pointer to an array.3. The function pointer : int* (*fun) (int *p1,int *p2)
Pointer to the array: int (* P) [5];
Defines a one-dimensional array pointing to the number of elements whose array element is int type is 5;
It can also be understood as the first element of a two-dimensional array, as if int * P points to the
Const is a New Keyword introduced in C ++, which brings great convenience to C ++ programming. The pointer to the const object and the const pointer are two very similar concepts. They are very easy to confuse for beginners. 1. pointer to the const
By combining structures and pointers, you can create powerful data structures. This blog is only for the single linked list to see.Link List Description:Each node of a linked list is a struct with two elements: 1, a pointer to the next node, and the
3.9 Pointer to memory locationOne day, two variables were encountered on the street:"Where do you live, man?" I'll see you sometime. ”"Oh, my home in the static storage area of the 0x0049a024 number, where's your home?" ”"My home in the dynamic
This is a tough thing to remember, because it has never been used. To sum up, I will not check it on C ++ primer later.
Const pointers are classified into three types:
1. pointer to the const object (1) definition form: const double * PT; // const
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.